package com.unlcn.ils.kas.util;

import com.unlcn.ils.kas.dao.model.sysadmin.bo.AccountUserBo;
import com.unlcn.ils.kas.service.account.AccountService;
import com.unlcn.ils.kas.service.security.config.JwtSettings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by zhaoguixin on 2017/12/7.
 */
@Component
public class UserUtil {

    @Autowired
    private AccountService accountService;

    @Autowired
    private JwtSettings jwtSettings;

    public AccountUserBo getAcUser(HttpServletRequest request){
        String token = request.getHeader(jwtSettings.getHeader());
        return accountService.getAccountInfo();
    }

    public Integer getUserId(HttpServletRequest request){
        String token = request.getHeader(jwtSettings.getHeader());
        return accountService.getAccountInfo().getUserId();
    }


}
